
import "./collectAnswer.less"
import { useState } from "react"
import { Dialog } from 'antd-mobile'
import {calculationTime} from "../../../utils/time"
function CollectAnswer() {
    document.title = "问题管理"
    const [data, setData] = useState(
        [
            {
                isShower: false,
                isshanchu: false,
                islike:false,
                iscollect:false
            },
            {
                isShower: false,
                isshanchu: true,
                islike:false,
                iscollect:false
            },
            {
                isShower: false,
                isshanchu: true,
                islike:false,
                iscollect:false
            },
            {
                isShower: false,
                isshanchu: true,
                islike:false,
                iscollect:true
            },
            {
                isShower: false,
                isshanchu: true,
                islike:true,
                iscollect:false
            },
            {
                isShower: false,
                isshanchu: true,
                islike:false,
                iscollect:false
            },
        ]
    )
    const likeFun = (item,index) => {
        let t = [...data]
        t[index].islike = !item.islike
        setData(t)
        console.log("点赞");
    }
    const collectFun = (item,index) => {
        let t = [...data]
        t[index].iscollect = !item.iscollect
        setData(t)
        console.log("收藏");
    }
    return (
        <div className="concernedProblem">
            {data.map((item, index) => (
                <div className="question-item"  key={index}>
                    <div className="question-title">如何在保证装修质量前提下最大程度大大咧咧等等</div>
                    <div className="question-content ">
                    如何在保证装修质量前提下最大程度节如何在保证装修质量前提下最大程度节如何在保证装修质量前提下最大程度节如何在保证装修质量前提下最大程度节撒上记得记得空间打开
                    </div>
                    <div className="question-time">{calculationTime("2023.02.12 10:22:21")}</div>
                    <div className="question-info">
                        <div className="question-info-left">
                            <div>
                                 {
                                    item.islike ?
                                      <img onClick={()=>likeFun(item,index)} src={require("../../../assets/wendaguanli/wdgl_good_sel@2.png")} alt="" />:
                                      <img onClick={()=>likeFun(item,index)} src={require("../../../assets/wendaguanli/wdgl_good_unsel@2.png")} alt="" />
                                 } 
                                 10</div>
                            <div >
                            {
                                    item.iscollect ?
                                      <img onClick={()=>collectFun(item,index)} src={require("../../../assets/wendaguanli/wdgl_collection_sel@2.png")} alt="" />:
                                      <img onClick={()=>collectFun(item,index)} src={require("../../../assets/wendaguanli/wdgl_collection_unsel@2.png")} alt="" />
                                 } 
                                 10</div>
                           
                            <div>                  
                                     <img src={require("../../../assets/wendaguanli/wdgl_comment@2.png")} alt="" /> 
                                 10
                            </div>
                            <div>                  
                                     <img src={require("../../../assets/wendaguanli/wdgl_fenxiang@2.png")} alt="" />
                            </div>
                            </div>
                      
                        <div className="question-info-right">
                            <img onClick={(e) => {
                                if (!item.isShower){
                                    data.forEach(item => item.isShower = false) 
                                }  
                                let t = [...data]
                                t[index].isShower =  !item.isShower
                                setData(t)

                            }} src={require("../../../assets/wendaguanli/wdgl_gengduo@2.png")} alt="" />
                            {
                                item.isShower && <div className="question-info-right-img">
                                    <img onClick={() => {
                                         let t = [...data]
                                         t[index].isShower =  !item.isShower
                                         setData(t)
                                        Dialog.confirm({
                                            content: '是否提交申请',
                                            title: "提示",
                                            onConfirm: async () => {
                                               
                                                console.log("确定");
                                            },
                                        })

                                    }} src={require("../../../assets/wendaguanli/wdgl_qipao_jubao@2.png")} alt="" />
                                </div>
                            }
                        </div>
                    </div>
                </div>
            ))
            }
        </div>
    )
}
export default CollectAnswer